﻿using AntDesign;
using SageKing.Cache.Contracts;
using SageKing.Core.Contracts;
using Microsoft.AspNetCore.Components;


namespace SageKing.UI.Blazor.SageKingAntDesign.Contracts;

public interface IMenuTab<TEntity, TId> where TEntity : class, ISysMenu, new()
{
    public IMenuTab<TEntity, TId> MeTab { get;  }

    public IBaseServiceCache<TEntity, TId> MenuService { get; }

    public TId menuid { get; set; }

    public string TabTitle { get; set; }

    public string TabIcon { get; set; }

    public RenderFragment GetPageTitle();

    public async Task InitTabTitle()
    {
        if (menuid.IsNullOrEmpty())
        {
            return;
        }
        var getmenu = await MenuService.GetDetailCache(menuid);
        if (getmenu == null)
        {
            return;
        }
        TabIcon = getmenu.Icon.IsNullOrEmptyToDefault("home");
        TabTitle = getmenu.Title;
    }
}
